<!--  -->
<template>
  <div id="demo01">
    <h1>Demo01组件</h1>
    <h2>从Demo02接受的收据：{{msg}}</h2>
    <button @click="fasong">发送数据给Demo02</button>
    <demo-01-son></demo-01-son>
  </div>

</template>

<script>
import Demo01Son from "./Demo01Son.vue"
export default {
  name: "Demo01",
  data () {
    return {
      msg: ''
    }
  },
  components: {
    Demo01Son
  },
  methods: {
    test01 (data) {
      console.log(data);
      this.msg = data
    },
    fasong () {
      this.$EventBus.$emit("send", "我是Demo01页面");
    }
  },
  mounted () {
    // console.log(this);
    // 2.接受全局的haha事件
    this.$EventBus.$on('haha', this.test01);

  }
}
</script>
<style scoped>
#demo01 {
  background-color: red;
  padding: 20px;
  margin-bottom: 20px;
}
</style>